/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.contents;

import javax.swing.JComponent;
import javax.swing.JFrame;

import model.Content;
import model.ContentType;

/**
 * 
 * @author Yang Wang <yang@digitalmenubox.com>
 */
public abstract class ContentBox extends JComponent {
	/*
	 * this is only used for testing purposes
	 */

	public static ContentBox getContentBox(Content c) {
		ContentBox contentBox = null;
		if (c.getType() == ContentType.IMAGE) {
			contentBox = new ImageBox(c);
		} else if (c.getType() == ContentType.VIDEO) {
			contentBox = new XuggleVideoBox(c);
		} else if (c.getType() == ContentType.TEXT) {
			contentBox = new TextLabelBox(c.getContent());
		} else if (c.getType() == ContentType.GIF) {
			// contentBox = new TextLabelBox(c.getContent());
		}
		return contentBox;
	}

	/*
	 * selects an appropriate content box for the given content
	 */
	public static ContentBox getContentBox(Content c, int width, int height) {
		ContentBox contentBox = null;
		if (c.getType() == ContentType.IMAGE) {
			contentBox = new ImageBox(c, width, height);
		} else if (c.getType() == ContentType.VIDEO) {
			contentBox = new XuggleVideoBox(c, width, height);
		} else if (c.getType() == ContentType.TEXT) {
			contentBox = new TextLabelBox(c.getContent(), width, height);
		} else if (c.getType() == ContentType.GIF) {
			contentBox = new AnimatedGifBox(c.getContent(), width, height);
		}
		return contentBox;
	}

	public abstract String getContent();

	public static void main(String[] args) {
		JFrame frame = new JFrame("test");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setBounds(200, 200, 800, 800);
		ContentBox cb = ContentBox.getContentBox(new Content(5));

		frame.add(cb);
		frame.pack();
		frame.setVisible(true);

	}

	// telling the content box to do clean up work before it gets disposed;
	public abstract void cleanUp();

	public abstract void reinitialize();

	public abstract void initialize();

	public void transition(Content c) {
	}

	public abstract boolean isSuccessfullyInitialized();
}
